//
//  BanBu_ImageCell.m
// Halfarea
//
//  Created by Wang Xj on 14-1-8.
//
//

#import "BanBu_ImageCell.h"
#import "BanBu_WatermarkView.h"

@implementation BanBu_ImageCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor = [UIColor clearColor];
        
        //第一个图片
        self.watermarkView1 = [[[BanBu_WatermarkView alloc]init] autorelease];
        self.watermarkView1.userInteractionEnabled = YES;
        
        UITapGestureRecognizer * tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)];
        [self.watermarkView1 addGestureRecognizer:tap1];
        [tap1 release];
        [self addSubview:self.watermarkView1];
        
        //第一条竖线
        UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(108, 0, 1.0, 85.0)];
        lineView.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
        [self.contentView addSubview:lineView];
        [lineView release];
        
        //第二个图片
        self.watermarkView2 = [[[BanBu_WatermarkView alloc]init] autorelease];
        self.watermarkView2.userInteractionEnabled = YES;
        
        UITapGestureRecognizer * tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)];
        [self.watermarkView2 addGestureRecognizer:tap2];
        [tap2 release];
        
        [self addSubview:self.watermarkView2];
        
        //第二条竖线
        UIView * lineView2 = [[UIView alloc] initWithFrame:CGRectMake(211, 0, 1.0, 85.0)];
        lineView2.backgroundColor = [UIColor colorWithRed:224.0/255 green:224.0/255 blue:224.0/255 alpha:1.0];
        [self.contentView addSubview:lineView2];
        [lineView2 release];
        
        //第三个图片
        self.watermarkView3 = [[[BanBu_WatermarkView alloc]init] autorelease];
        self.watermarkView3.userInteractionEnabled = YES;
        
        UITapGestureRecognizer * tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)];
        [self.watermarkView3 addGestureRecognizer:tap3];
        [tap3 release];
        
        [self addSubview:self.watermarkView3];
    }
    return self;
}
-(void)dealloc
{
    [_watermarkView1 release],_watermarkView1 = nil;
    [_watermarkView2 release],_watermarkView2 = nil;
    [_watermarkView3 release],_watermarkView3 = nil;
    [super dealloc];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

-(void)initFirstWatermarkImage:(NSString *)imagePath1
{
    self.watermarkView1.frame = CGRectMake(15, 0, 84, 84);
    
    //初始化图片
    self.watermarkView1.imagePath = imagePath1;
    [self.watermarkView1 initWithImageView:CGRectMake(0, 0, 84, 84)];
    
    self.watermarkView1.imageView.image = [UIImage imageWithContentsOfFile:imagePath1];
}

-(void)initSecondWatermarkImage:(NSString *)imagePath2
{
    self.watermarkView2.frame = CGRectMake(118, 0, 84, 84);
    
    //初始化图片
    self.watermarkView2.imagePath = imagePath2;
    [self.watermarkView2 initWithImageView:CGRectMake(0, 0, 84, 84)];
    
    self.watermarkView2.imageView.image = [UIImage imageWithContentsOfFile:imagePath2];
}

-(void)initThirdWatermarkImage:(NSString *)imagePath3
{
    self.watermarkView3.frame = CGRectMake(221, 0, 84, 84);
    
    //初始化图片
    self.watermarkView3.imagePath = imagePath3;
    [self.watermarkView3 initWithImageView:CGRectMake(0, 0, 84, 84)];
    
    self.watermarkView3.imageView.image = [UIImage imageWithContentsOfFile:imagePath3];
}

-(void)tapGesture:(UITapGestureRecognizer *)sender
{
    if ([self.delegate respondsToSelector:@selector(didSelectedWatermarkView:)])
    {
        [self.delegate didSelectedWatermarkView:(BanBu_WatermarkView *)sender.view];
    }
}
@end
